<template>
  <div>
    <div style="margin-left: 10px;margin-bottom: 20px;">
      <el-radio v-model="m.type" :label="0" @change="changetab('/menu/folder')">目录</el-radio>
      <el-radio v-model="m.type" :label="1" @change="changetab('/menu/menu')">菜单</el-radio>
      <el-radio v-model="m.type" :label="2" @change="changetab('/menu/button')">按钮</el-radio>
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
  export default {
    props: ['menu'],
    data() {
      return {
        m:{

        }
      }
    },
    mounted() {
      var currentUrl = "";
      console.log(this.menu);
      if (this.menu.type == '0') {
        currentUrl = "/menu/folder";
      } else if (this.menu.type == '1') {
        currentUrl = "/menu/menu";
      } else {
        currentUrl = "/menu/button";
      }
      this.$router.push(currentUrl)
      this.m = this.copy(this.menu)
    },


    methods: {
      copy(obj) {
        var newobj = {};
        for (var attr in obj) {
          newobj[attr] = obj[attr];
        }
        return newobj;
      },
      changetab(url) {
        this.$router.replace(url)
      }
    }
  }
</script>

<style>

</style>
